<template>

    <div class="footerbox">
      <div class="footer-title">患者评论</div>

      <!-- 评论内容 -->
      <div id="comment">
      
        <div
          v-for="(item, index) in tainer1.a"
          :key="item.id"
          class="ask-content-items"
        >
          <img src="../../img/mh/3398348946228434991-22.png" alt="" />
          <span>{{ item.username }}</span>
          <div>{{ item.content }}</div>
        </div>
        <div class="addbtn"><span @click="addcount1">点击查看更多</span></div>
      </div>
  
    </div>

</template>

<script setup lang="ts">
import { onMounted, ref, getCurrentInstance } from "vue";
let { proxy } = getCurrentInstance();
let tainer1 = ref({ a: [] });
let count = 2;
//得到用户id
let props = defineProps(["footid"]);
// console.log(props.mainid);
onMounted(async () => {
  //请求问题表
  let res = await proxy.$axios("/getcomment", {
    params: { did: props.footid, count: count },
  });
  // tainer.value.a=res.data
  for (let i = 0; i < res.data.length; i++) {
    tainer1.value.a.push(res.data[i]);
  }
  
  
  console.log(res);
});

let addcount1 = async () => {
  //获取问题表长度
   let res0 = await proxy.$axios("/getcommentlen")
  //  console.log(res0);
   if (res0.data.length<=count) {
      alert("已经到底啦 别点了")
      return
   }
   
  count += 8;
  let res = await proxy.$axios("/getcomment", {
    params: { did: props.footid, count: count },
  });
  // tainer.value.a=res.data
   tainer1.value.a.length=0
  for (let i = 0; i < res.data.length; i++) {
    tainer1.value.a.push(res.data[i]);
  }
};
</script>

<style scoped lang="scss">
.footerbox {
  // width:400px ;
  // height: 400px;
  // background-color: yellow;
  

  .footer-title {
    padding: 20px 0 10px;
    color: #333;
    font-weight: 600;
    font-size: 28px;
    // line-height: 1.09
  }
  #comment{

    .ask-content-items {
      border-bottom: 1px solid #ebebeb;
      margin-bottom: 20px;
      padding-bottom: 20px;
      img {
        width: 25px;
        height: 25px;
        vertical-align: middle;
      }
      span {
        font-size: 17px;
        display: inline-block;
        vertical-align: middle;
        margin-left: 5px;
        color: #333;
      }
      div {
        margin-top: 12px;
        color: #4d4d4d;
        width: 860px;
        word-break: break-all;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3; /* 这里是超出几行省略 */
        overflow: hidden;
      }
    }
  }

  .addbtn {
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-size: 14px;
  margin-bottom: 20px;
  margin-top: 30px;

  span {
    padding: 5px 15px;
    color: #00c792;
    background-color: #f5f5f5;
    border-radius: 15px;
    cursor: pointer;
    caret-color: transparent;
  }
}
}
</style>
